package main.java.ssm.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ssm.dao.IUserDao;
import ssm.pojo.User;
import ssm.service.IUserService;

import java.util.List;
import java.util.Map;

/**
 * Author: silence
 * Date: 17-5-26.
 */
@Service("IUserService")
public class UserServiceImpl implements IUserService {

    @Autowired IUserDao userDao;

    /**
     * 通过ID查询单个用户信息
     * @param userId
     * @return
     */
    @Override
    public User getUserById(int userId) {
        User user=userDao.selectByPrimaryKey(userId);
        return user;
    }

    /**
     * 通过ID查询所有用户信息
     * @return
     */
    @Override
    public List<User> findAllByQuery() {
        List<User> user1= (List<User>) userDao.findAllByQuery();
        return user1;
    }


    @Override
    public int addUser(User user) {
        return userDao.insert(user);
    }



    @Override
    public User findUserByUsername(String username) {
        User user=userDao.findUserByUsername(username);
        return user;
    }

    @Override
    public int updateByPrimaryKey(User record) {
        return userDao.updateByPrimaryKey(record);
    }

    @Override
    public int deleteByPrimaryKey(Integer Id) {
        return userDao.deleteByPrimaryKey(Id);
    }

    @Override
    public int getTotal(Map<String, Object> map) {
        return userDao.getTotal(map);
    }

    @Override
    public List<User> list(Map<String, Object> map) {
        return userDao.list(map);
    }

    @Override
    public List<User> findUsersByName(String name) {
        return userDao.findUsersByName(name);//
    }
}
